<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .big{
            width: 300px;
            height: 30px;
            border:1px solid black;
            position: relative;

        }
        .small {
           height: 30px;
            border:1px solid red;
            position: absolute;
            left: 0;
            top: 0;
            background-color: rgb(219, 140, 140);
            box-sizing: border-box;
            display: none;
        }

        
    </style>
</head>
<body>
    <div class="big">
        <div class="small"></div>

    </div>
    <script>
        const big=document.querySelector('.big')
        const small=document.querySelector('.small')
        let num  = 0;
        let t =setInterval(function(){
            small.style.display='block'
            num+=10;
            if(num>=big.clientWidth) {
                num=big.clientWidth
                clearInterval(t)
            }
            small.innerHTML=parseInt(num/big.clientWidth*100)+'%'
            small.style.width=num+'px'
        },100)

    </script>
</body>
</html>